//
//  YHMachineManagementPullDownRecordViewController.m
//  YHApp
//
//  Created by -- on 2021/7/20.
//

#import "HAMachinePullDownRecordVC.h"
#import "SGPagingView.h"
#import "HAMachinePullDownRecordSubVC.h"

@interface HAMachinePullDownRecordVC ()<SGPageTitleViewDelegate,SGPageContentViewDelegate>

@property (nonatomic, strong) SGPageTitleView *pageTitleView;

@property (nonatomic, strong) SGPageContentView *pageContentView;

@end

@implementation HAMachinePullDownRecordVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.baseTLabel.text = @"机具记录";

    NSMutableArray *titArr = [NSMutableArray array];
    NSMutableArray *vcArr = [NSMutableArray array];
    
    [titArr addObject:@"拔发记录"];
    [titArr addObject:@"接收记录"];

    HAMachinePullDownRecordSubVC *vc0 = [[HAMachinePullDownRecordSubVC alloc]init];
    vc0.source_id = @"1";
    HAMachinePullDownRecordSubVC *vc1 = [[HAMachinePullDownRecordSubVC alloc]init];
    vc1.source_id = @"2";

    [vcArr addObject:vc0];
    [vcArr addObject:vc1];
    
    self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, app_topH+44, kUIScreen_w, 44) delegate:self titleNames:titArr titleFont:[UIFont systemFontOfSize:18]];
    [self.view addSubview:self.pageTitleView];
    self.pageTitleView.isTitleGradientEffect = NO;
    self.pageTitleView.indicatorLengthStyle = SGIndicatorLengthStyleEqual;
    self.pageTitleView.isNeedBounces = NO;
    self.pageTitleView.titleColorStateNormal = [UIColor colorWithHexString:@"#666F83"];
    self.pageTitleView.titleColorStateSelected = [UIColor colorWithHexString:@"#21252A"];
    self.pageTitleView.indicatorColor = [UIColor colorWithHexString:@"#000000"];
    self.pageTitleView.indicatorHeight = 1;
    self.pageTitleView.titleTextScaling = 0;
    self.pageTitleView.isOpenTitleTextZoom = YES;
    
    CGFloat contentViewHeight = kUIScreen_h-app_topH-64-44-5;
    self.pageContentView = [[SGPageContentView alloc] initWithFrame:CGRectMake(0, app_topH+44+44+5, kUIScreen_w, contentViewHeight) parentVC:self childVCs:vcArr];
    self.pageContentView.isScrollEnabled = YES;
    self.pageContentView.delegatePageContentView = self;
    [self.view addSubview:_pageContentView];

    [self.pageContentView setPageCententViewCurrentIndex:0];
    self.pageTitleView.selectedIndex = 0;

    // Do any additional setup after loading the view.
}

- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex {
    [self.pageContentView setPageCententViewCurrentIndex:selectedIndex];
}

- (void)pageContentView:(SGPageContentView *)pageContentView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex {
    self.pageTitleView.resetSelectedIndex = targetIndex;
}



@end
